﻿using System.Collections.Generic;
using System.Linq;
using SolidDemo.Business.Interfaces;
using SolidDemo.Data.Seeded;

namespace SolidDemo.Business.Services
{
    public class PumpSelectService : GomtuuService, IPumpSelectService
    {
        public PumpSelectService(IGenericRepository repository, ILogRepository logRepository): base(repository, logRepository){}

        public List<Pump> SelectBy_Stocked_DiameterMm_MinFlowLpm_MaxFlowLpm(bool isStockedOnly, int diameterMm, double minFlowLpm, double maxFlowLpm)
        {
            var allPumps = _repository.LoadAll<Pump>();

            if (isStockedOnly)
            {
                allPumps = allPumps.Where(p => p.IsStocked).ToList();
            }

            allPumps = allPumps.Where(p => p.DiameterMm <= diameterMm && p.MinFlowLPerMin <= minFlowLpm && p.MaxFlowLPerMin >= maxFlowLpm).ToList();

            return allPumps;
        }
    }
}
